package com.gtw.modules.sys.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.gtw.modules.sys.service.SysPropertyService;
import com.gtw.modules.dao.TbPropertyDao;
import com.gtw.modules.entity.TbProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;


/**
 * @author wuye
 */
@Service("SysPropertyservice")
public class SysPropertyServiceImpl implements SysPropertyService {

    @Autowired
    private TbPropertyDao propertyDao;

    @Override
    public Page<TbProperty> queryPageList(Page<TbProperty> page, Map<String, Object> map) {
        page.setRecords(propertyDao.queryPageList(page, map));
        return page;
    }

    @Override
    public TbProperty queryObject(Integer id) {
        return propertyDao.selectByPrimaryKey(id);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void save(TbProperty property) {
        propertyDao.insert(property);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void update(TbProperty property) {
        propertyDao.updateByPrimaryKey(property);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void delete(Integer id) {
        TbProperty tcp = propertyDao.selectByPrimaryKey(id);
        tcp.setIsdelete(true);
        propertyDao.updateByPrimaryKey(tcp);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void deleteBatch(Integer[] ids) {
        for (int i = 0; i < ids.length; i++) {
            TbProperty tcp = propertyDao.selectByPrimaryKey(ids[i]);
            tcp.setIsdelete(true);
            propertyDao.updateByPrimaryKey(tcp);
        }
    }

    @Override
    public List<TbProperty> findaLLProperty() {
        return propertyDao.findaLLProperty();
    }

    @Override
    public List<TbProperty> findByName(String name) {
        return propertyDao.findByName(name);
    }

    @Override
    public List<TbProperty> findByData(String name, String value) {
        return propertyDao.findByData(name,value);
    }

}
